home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Kohle1.cpp < prev    next >
C/C++ Source or Header  |  1998-12-14  |  1KB  |  49 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Kohle1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. float Kapital, Zinsen, Prozent; int Nr, Laufzeit;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.     : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Button1Click(TObject *Sender)
  17. {
  18.   Nr++;
  19.   if (Nr == 1)
  20.   {
  21.     Kapital = StrToFloat (Edit1->Text);
  22.     Label1->Caption = "Wie hoch soll der Zinssatz sein?";
  23.     Edit1->Text = "";
  24.     Edit1->SetFocus ();
  25.   }
  26.   if (Nr == 2)
  27.   {
  28.     Prozent = StrToFloat (Edit1->Text);
  29.     Laufzeit = 0;
  30.     while (Kapital < 1000000)
  31.     {
  32.       Zinsen = Kapital * Prozent / 100;
  33.       Kapital = Kapital + Zinsen;
  34.       Laufzeit++;
  35.     }
  36.     if (Laufzeit > 0)
  37.       Label1->Caption = "Dein Geld mu▀ "
  38.         + IntToStr (Laufzeit) + " Jahre auf der Bank braten";
  39.     else
  40.       Label1->Caption = "Willkommen im Club der MillionΣre!";
  41.   }
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::FormCreate(TObject *Sender)
  45. {
  46.   Nr = 0;
  47. }
  48. //---------------------------------------------------------------------------
  49.